// 封装医院设置相关发送ajax请求的函数
// 引入axios实例
import { request } from '@utils/http'
// 引入ts类型
import { IhospitalsetRes, IaddHosParams } from './model/hospitalSetTypes'
// 发送请求获取医院设置表格的数据
export function reqGetHospitalSets(
  page: number,
  limit: number,
  hosname?: string,
  hoscode?: string
) {
  return request.get<any, IhospitalsetRes>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
      },
    }
  )
}

// 添加医院设置
export function reqAddHospitalSet({
  hosname,
  hoscode,
  apiUrl,
  contactsName,
  contactsPhone,
}: IaddHosParams) {
  // 因为添加医院设置服务器没有返回具体的数据.所以不需要描述响应数据的类型
  return request.post('/admin/hosp/hospitalSet/save', {
    hosname,
    hoscode,
    apiUrl,
    contactsName,
    contactsPhone,
  })
}

// 获取一条医院设置信息
export function reqGetOneHospitalSet(id: string) {
  return request.get<any, IaddHosParams>(`/admin/hosp/hospitalSet/get/${id}`)
}

// 修改一条医院设置信息
export function reqUpdateHospotalSet(params: IaddHosParams) {
  return request.put(`/admin/hosp/hospitalSet/update`, params)
}

// 删除一条医院设置
export const reqDelOneHospitalSet = (id: string) =>
  request.delete(`/admin/hosp/hospitalSet/remove/${id}`)

// 批量删除多条医院设置
export const reqBatchDelHospitalSets = (ids: string[]) =>
  request.delete(`/admin/hosp/hospitalSet/batchRemove`, {
    data: ids,
  })
